<template>
  <div class="page">
    <div class="clear"></div>
    <div class="user_box" @click="$goPage('/edit_user_info')">
      <el-row>
        <el-col :span="5">
          <img :src="user_info.portrait" class="head_img">
        </el-col>
        <el-col :span="19">
          <div class="username">{{ user_info.c_name }} <i style="color: red" v-if="user_info.vip_status">v</i></div>
          <div class="desc">编辑个人资料</div>
        </el-col>
      </el-row>
    </div>
    <div class="vip_box" @click="$goPage('open_vip')">
      <div>VIP享受外卖8折优惠</div>
      <el-tag class="kaitong" size="small" v-if="!user_info.vip_status">去开通</el-tag>
      <el-tag class="kaitong" size="small" v-else>{{ user_info.vip_time }}到期</el-tag>
    </div>
    <div class="menu_box">
      <div class="menu_item" @click="wait">
        <div>
          <Icon class="icon2" type="ios-text"/>
          <span>消息</span>
        </div>
        <div>
          <Icon type="ios-arrow-forward"/>
        </div>
      </div>
      <div class="menu_item" @click="addr">
        <div>
          <Icon class="icon2" type="ios-paper"/>
          <span>我的地址</span>
        </div>
        <div>
          <Icon type="ios-arrow-forward"/>
        </div>
      </div>
      <div class="menu_item" @click="collect">
        <div>
          <Icon class="icon2" type="ios-trending-up"/>
          <span>我的收藏</span>
        </div>
        <div>
          <Icon type="ios-arrow-forward"/>
        </div>
      </div>
      <div class="menu_item" @click="wait">
        <div>
          <Icon class="icon2" type="ios-settings"/>
          <span>浏览记录</span>
        </div>
        <div>
          <Icon type="ios-arrow-forward"/>
        </div>
      </div>
      <div class="menu_item" @click="$goPage('vip_record')">
        <div>
          <Icon class="icon2" type="ios-ribbon"/>
          <span>开通vip记录</span>
        </div>
        <div>
          <Icon type="ios-arrow-forward"/>
        </div>
      </div>

      <div class="menu_item" @click="wait">
        <div>
          <Icon class="icon2" type="ios-hand"/>
          <span>意见反馈</span>
        </div>
        <div>
          <Icon type="ios-arrow-forward"/>
        </div>
      </div>
    </div>
    <BottomBar :index="3"></BottomBar>
  </div>
</template>

<script>
import BottomBar from "@/components/BottomBar";

export default {
  name: "HomeView.vue",
  components: {
    BottomBar,
  },
  data() {
    return {
      user_info: {}
    }
  },
  mounted() {
    this.getData()
  },
  methods: {
    collect(){
      this.$router.push('/collect')
    },
    addr(){
      this.$router.push('/location')
    },
    getData() {
      this.$axios.get("customer/userinfo/",{
        headers:{
          'Authorization':localStorage.getItem('token') || ''
        }
      }).then(res => {
        if (res.data.code == 200) {
          console.log('>>>>>>',res.data.data)
          this.user_info = res.data.data
        } else {
          this.$message.error(res.data.msg)
        }
      })
    },
    wait() {
      this.error("待开发")
    }
  }
}
</script>

<style>
body {
  margin: 0;
}
</style>
<style scoped>
.page {
  background-color: rgb(242, 242, 242);
  height: 100vh; /* vh 屏幕高度 */
}

.user_box {
  padding: 10px;
  margin: 20px 2.5%;
}

.head_img {
  width: 60px;
  height: 60px;
  border-radius: 50%;
}

.username {
  font-size: 20px;
  margin: 4px 0 8px;
  font-weight: bold;
}

.desc {
  color: #999999;
  font-size: 12px;
}

.vip_box {
  height: 45px;
  width: calc(95% - 40px);
  margin: 0 auto;
  border-radius: 10px 10px 0 0;
  background-image: linear-gradient(rgb(247, 208, 177), rgb(244, 220, 202));
  margin-top: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  line-height: 45px;
  padding: 0 20px;
}

.vip_box div {
  font-weight: bold;
}

.kaitong {
  background-color: rgb(65, 65, 65);
  color: rgb(247, 208, 177);
  border: 1px solid rgb(247, 208, 177);
  border-radius: 20px;
}

.menu_box {
  margin: 0 10px;
  background-color: #FFFFFF;
  border-radius: 10px;
  padding-top: 10px;
}

.menu_item {
  display: flex;
  justify-content: space-between;
  margin: 0 15px;
  border-bottom: 1px solid #CCCCCC;
  padding: 15px 0 15px;
}

.menu_item:last-child {
  border-bottom: none;
}

/*.noborder{*/
/*  border-bottom: none;*/
/*}*/

.menu_item i {
  margin-right: 6px;
}

.icon {
  font-size: 26px;
}

.icon2 {
  font-size: 20px;
}


</style>